package com.qiang.model;
/**
 * @package: com.qiang.model
 * @title: Node
 * @projectName: burning
 * @description: //TODO
 * @author zhuhongqiang3
 * @date:  2020-08-07 16:35
 * @version: V1.0
 * @retrun com.qiang.model.burning
 */
public class Node {
    public Node pre;// 上一个节点

    public Node next;// 下一个节点

     int data;// 数据

    public Node(int data) {
        this.data = data;
    }

    public void append(Node node) {
        if (this.next == null) {
            this.next = node;
            node.pre = this;
        } else {
            this.next.append(node);
        }

    }

    public Node getPre() {
        return pre;
    }

    public void setPre(Node pre) {
        this.pre = pre;
    }

    public Node getNext() {
        return next;
    }

    public void setNext(Node next) {
        this.next = next;
    }

    public void setData(int data) {
        this.data = data;
    }

    public boolean hasPre() {
        return this.pre != null;
    }

    public boolean hasNext() {
        return this.next != null;
    }

    public int getData() {
        return data;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"pre\":")
                .append(pre);
        sb.append(",\"next\":")
                .append(next);
        sb.append(",\"data\":")
                .append(data);
        sb.append('}');
        return sb.toString();
    }
}
